package com.calm.editor.entity;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.Table;
import javax.persistence.Transient;

@Table(name = "XHTML_ELEMENT")
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn()
public class Element {
	@Id
	@Column(name = "ID")
	private Integer id;
	
	@Column(name = "ELEMENT_ID")
	private String elementId;
	
	@Column(name = "TAG_NAME")
	private String tagName;
	
	@Column(name = "DELETE_CLASS")
	private String deleteClass;
	
	@Column(name = "NAMESPACE")
	private String namespace;
	
	@Transient
	private List<Namespace> namespaces;
	
	@ElementCollection(fetch=FetchType.EAGER)
	@JoinTable(name = "XHTML_ELEMENT_ATTR")
	@JoinColumn(name = "ELEMENT_ID")
	private Map<String, String> attrs = new HashMap<String, String>();

	public String getElementId() {
		return elementId;
	}

	public void setElementId(String elementId) {
		this.elementId = elementId;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public List<Namespace> getNamespaces() {
		return namespaces;
	}

	public void setNamespaces(List<Namespace> namespaces) {
		this.namespaces = namespaces;
	}

	public Map<String, String> getAttrs() {
		return attrs;
	}

	public void setAttrs(Map<String, String> attrs) {
		this.attrs = attrs;
	}

	public String getDeleteClass() {
		return deleteClass;
	}

	public void setDeleteClass(String deleteClass) {
		this.deleteClass = deleteClass;
	}

	public String getTagName() {
		return tagName;
	}

	public void setTagName(String tagName) {
		this.tagName = tagName;
	}

	public String getNamespace() {
		return namespace;
	}

	public void setNamespace(String namespace) {
		this.namespace = namespace;
	}
}
